
#include "./common.h"
FILE *fp;
int mult_test(int a,int b,unsigned int lo,unsigned int hi,long oldlo,long oldhi){
    long aa=(long) a;
    long bb=(long) b;
    long ans=bb*aa;
    long tmp =(oldlo+(oldhi<<32));
    // printf("old:0x%016lx\n",tmp);
    ans+=tmp;
    unsigned tmplo=(ans)&0xffffffff;
    unsigned tmphi=(ans)>>32;
    printf("ans:0x%08x\t0x%08x\n",tmplo,tmphi);
    return lo==tmplo && hi == tmphi;

}
int gen_msub(){
    fprintf(fp,"TEST_MType(");
    int a=getRandInt32();
    int b=getRandInt32();
    a=0;
    long oldlo=(long)getRandInt32();
    long oldhi=(long)getRandInt32();
    long aa=(long) a;
    long bb=(long) b;
    long ans=bb*aa;
    long tmp =(oldlo+(oldhi<<32));
    // printf("old:0x%016lx\n",tmp);
    ans=tmp-ans;
    unsigned tmplo=(ans)&0xffffffff;
    unsigned tmphi=(ans)>>32;
    fprintf(fp,"0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,msub)\n",a,b,tmplo,tmphi,(int)oldlo,(int)oldhi);

}
int main(int argc, char const *argv[])
{

    fp=fopen("../asm/msub.S","w");
    srand(time(NULL));
    for (int i = 0; i < 50; i++)
    {
        gen_msub();
    }


    return 0;
}